/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2011
 */

package com.tech15.core.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.tech15.core.model.*;
import com.tech15.core.dao.*;
import com.tech15.core.service.*;
import com.tech15.core.vo.query.*;

/**
 * @author 胡作正 email:zuozhenghu@sina.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "SYS_MODULE_FUNCTION")
public class ModuleFunction extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "ModuleFunction";
	public static final String ALIAS_FUNID = "序号";
	public static final String ALIAS_NAME = "名称";
	public static final String ALIAS_URL = "连接url";
	public static final String ALIAS_REMARK = "备注";
	public static final String ALIAS_TYPE = "类型";
	public static final String ALIAS_MDID = "模块id";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * 序号       db_column: FUNID 
     */ 	
	
	private Long funid;
    /**
     * 名称       db_column: NAME 
     */ 	
	@Length(max=32)
	private java.lang.String name;
    /**
     * 连接url       db_column: URL 
     */ 	
	@Length(max=200)
	private java.lang.String url;
    /**
     * 备注       db_column: REMARK 
     */ 	
	@Length(max=200)
	private java.lang.String remark;
    /**
     * 类型       db_column: TYPE 
     */ 	
	@Max(127)
	private Integer type;
    /**
     * 模块id       db_column: MDID 
     */ 	
	
	private Long mdid;
	//columns END


	public ModuleFunction(){
	}

	public ModuleFunction(
		Long funid
	){
		this.funid = funid;
	}

	

	public void setFunid(Long value) {
		this.funid = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "FUNID", unique = true, nullable = false, insertable = true, updatable = true, length = 22)
	public Long getFunid() {
		return this.funid;
	}
	
	@Column(name = "NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 32)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	@Column(name = "URL", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getUrl() {
		return this.url;
	}
	
	public void setUrl(java.lang.String value) {
		this.url = value;
	}
	
	@Column(name = "REMARK", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getRemark() {
		return this.remark;
	}
	
	public void setRemark(java.lang.String value) {
		this.remark = value;
	}
	
	@Column(name = "TYPE", unique = false, nullable = true, insertable = true, updatable = true, length = 2)
	public Integer getType() {
		return this.type;
	}
	
	public void setType(Integer value) {
		this.type = value;
	}
	
	@Column(name = "MDID", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getMdid() {
		return this.mdid;
	}
	
	public void setMdid(Long value) {
		this.mdid = value;
	}
	
	
	private Module module;
	public void setModule(Module module){
		this.module = module;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "MDID",nullable = false, insertable = false, updatable = false) 
	})
	public Module getModule() {
		return module;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Funid",getFunid())
			.append("Name",getName())
			.append("Url",getUrl())
			.append("Remark",getRemark())
			.append("Type",getType())
			.append("Mdid",getMdid())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getFunid())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof ModuleFunction == false) return false;
		if(this == obj) return true;
		ModuleFunction other = (ModuleFunction)obj;
		return new EqualsBuilder()
			.append(getFunid(),other.getFunid())
			.isEquals();
	}
}

